﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

namespace ERPStore.Coupons.Repositories.Mapping
{
	public class CouponMap : EntityTypeConfiguration<Datas.CouponData>
	{
		public CouponMap()
		{
			this.HasKey(e => e.Id);
			Property(e => e.Id)
				.IsRequired()
				.HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);
			Property(e => e.Code)
				.IsRequired()
				.HasMaxLength(50);
			Property(e => e.Description)
				.IsOptional();

			Property(e => e.ExpirationDate)
				.IsOptional();
			Property(e => e.MaximumUseCount)
				.IsOptional();
			Property(e => e.UsedCount)
				.IsOptional();
			Property(e => e.MinimumPurchase)
				.IsOptional();
			Property(e => e.MinimumItemCount)
				.IsOptional();
			Property(e => e.ProductIdListString)
				.IsOptional();
			Property(e => e.ProductCategoryIdListString)
				.IsOptional();
			Property(e => e.BrandIdListString)
				.IsOptional();

			Property(e => e.CreationDate)
				.IsRequired();

			Property(e => e.LastUpdate)
				.IsRequired();

			Property(e => e.VendorCode)
				.IsOptional();

			Property(e => e.IsFree)
				.IsRequired();

			Property(e => e.DiscountPercent)
				.IsOptional();

			Property(e => e.CreditAmount)
				.IsOptional();

			Property(e => e.Version)
				.HasColumnType("timestamp")
				.IsConcurrencyToken()
				.HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Computed);

			Property(e => e.ItemCount)
				.IsOptional();

			ToTable("Coupon");
		}
	}
}
